package cn.yangyumanage;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;

import androidx.appcompat.app.AppCompatActivity;

import java.util.Timer;
import java.util.TimerTask;

public class HelloActivity extends AppCompatActivity {
    private Timer timer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hello);
        initView();
    }

    @Override
    protected void onResume() {
        super.onResume();
        delayJump(300);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        timer.cancel();
    }

    private void initView() {
        statusBarSetting();
    }

    //设置状态栏
    private void statusBarSetting() {
        Window window = getWindow();
        //设置状态栏颜色为透明
        window.setStatusBarColor(getResources().getColor(R.color.transparent, null));
        //设置全屏且隐藏状态栏
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    }

    //延时跳转
    private void delayJump(int delay) {
        timer = new Timer();
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                Intent intent = new Intent(HelloActivity.this, LoginActivity.class);
                startActivity(intent);
                finish();
            }
        };
        timer.schedule(task, delay);
    }
}